if(USE_GLYCOL_CACHING)
  add_compile_definitions(EP_cache_GlycolSpecificHeat)
endif()

if(USE_PSYCH_ERRORS)
  add_compile_definitions(EP_psych_errors)
endif()

if(PYTHON_CLI)
  add_compile_definitions(EP_PYTHON_CLI)
endif()

set(test_src
    TestHelpers/IdfParser.cc
    TestHelpers/IdfParser.hh
    TestHelpers/CustomMatchers.hh
    Fixtures/EnergyPlusFixture.cc
    Fixtures/EnergyPlusFixture.hh
    Fixtures/IdfParserFixture.hh
    Fixtures/InputProcessorFixture.hh
    Fixtures/ResultsFrameworkFixture.hh
    Fixtures/SQLiteFixture.hh
    PhaseChangeModeling/HysteresisModel.unit.cc
    AdvancedAFN.unit.cc
    AirLoopHVACDOAS.unit.cc
    AirTerminalSingleDuct.unit.cc
    AirTerminalSingleDuctConstantVolumeNoReheat.unit.cc
    AirTerminalSingleDuctMixer.unit.cc
    AirTerminalSingleDuctPIUReheat.unit.cc
    AirflowNetworkHVAC.unit.cc
    AirflowNetworkConditions.unit.cc
    AirflowNetworkComponents.unit.cc
    Autosizing/All_Simple_Sizing.unit.cc
    Autosizing/AutosizingFixture.hh
    Autosizing/BaseClassSizing.unit.cc
    Autosizing/CoolingAirFlowSizing.unit.cc
    Autosizing/CoolingCapacitySizing.unit.cc
    Autosizing/CoolingSHRSizing.unit.cc
    Autosizing/CoolingWaterDesAirInletHumRatSizing.unit.cc
    Autosizing/CoolingWaterDesAirInletTempSizing.unit.cc
    Autosizing/CoolingWaterDesAirOutletHumRatSizing.unit.cc
    Autosizing/CoolingWaterDesAirOutletTempSizing.unit.cc
    Autosizing/CoolingWaterDesWaterInletTempSizing.unit.cc
    Autosizing/CoolingWaterNumofTubesPerRowSizing.unit.cc
    Autosizing/CoolingWaterflowSizing.unit.cc
    Autosizing/HeatingAirFlowSizing.unit.cc
    Autosizing/HeatingAirflowUASizing.unit.cc
    Autosizing/HeatingCapacitySizing.unit.cc
    Autosizing/HeatingWaterDesAirInletHumRatSizing.unit.cc
    Autosizing/HeatingWaterDesAirInletTempSizing.unit.cc
    Autosizing/HeatingWaterDesCoilLoadUsedForUASizing.unit.cc
    Autosizing/HeatingWaterDesCoilWaterVolFlowUsedForUASizing.unit.cc
    Autosizing/HeatingWaterflowSizing.unit.cc
    Autosizing/SystemAirFlowSizing.unit.cc
    Autosizing/WaterHeatingCapacitySizing.unit.cc
    Autosizing/WaterHeatingCoilUASizing.unit.cc
    BaseboardElectric.unit.cc
    BaseboardRadiator.unit.cc
    BoilerHotWater.unit.cc
    BoilerSteam.unit.cc
    BranchInputManager.unit.cc
    BranchNodeConnections.unit.cc
    CTElectricGenerator.unit.cc
    ChilledCeilingPanelSimple.unit.cc
    ChillerAbsorption.unit.cc
    ChillerConstantCOP.unit.cc
    ChillerElectric.unit.cc
    ChillerElectricEIR.unit.cc
    ChillerReformulatedEIR.unit.cc
    ChillerExhaustAbsorption.unit.cc
    ChillerGasAbsorption.unit.cc
    ChillerIndirectAbsorption.unit.cc
    Coils/CoilCoolingDX.unit.cc
    Coils/CoilCoolingDXCurveFitOperatingMode.unit.cc
    Coils/CoilCoolingDXCurveFitPerformance.unit.cc
    Coils/CoilCoolingDXCurveFitSpeed.unit.cc
    Coils/CoilCoolingDXFixture.hh
    CondenserLoopTowers.unit.cc
    Construction.unit.cc
    ConstructionInternalSource.unit.cc
    ConvectionCoefficients.unit.cc
    CoolTower.unit.cc
    CrossVentMgr.unit.cc
    CsvParser.unit.cc
    CurveManager.unit.cc
    CustomMatchers.unit.cc
    DElightManager.unit.cc
    DOASEffectOnZoneSizing.unit.cc
    DXCoils.unit.cc
    DataEnvironment.unit.cc
    DataHeatBalance.unit.cc
    DataPlant.unit.cc
    DataRuntimeLanguage.unit.cc
    DataSizing.unit.cc
    DataSurfaceColors.unit.cc
    DataSurfaces.unit.cc
    DataSystemVariables.unit.cc
    DataZoneEquipment.unit.cc
    Datasets.unit.cc
    DaylightingDevices.unit.cc
    DaylightingManager.unit.cc
    DemandResponse.unit.cc
    DesiccantDehumidifiers.unit.cc
    DisplacementVentMgr.unit.cc
    DualDuct.unit.cc
    DuctLoss.unit.cc
    EPVector.unit.cc
    EMSManager.unit.cc
    EarthTube.unit.cc
    EcoRoofManager.unit.cc
    EconomicLifeCycleCost.unit.cc
    EconomicTariff.unit.cc
    ElectricBaseboardRadiator.unit.cc
    ElectricPowerServiceManager.unit.cc
    EquipAndOperations.unit.cc
    EvaporativeCoolers.unit.cc
    EvaporativeFluidCoolers.unit.cc
    ExhaustSystem.unit.cc
    ExtendedHI.unit.cc
    ExteriorEnergyUse.unit.cc
    FanCoilUnits.unit.cc
    Fans.unit.cc
    FaultsManager.unit.cc
    FileSystem.unit.cc
    FiniteDifferenceGroundTemperatureModel.unit.cc
    FluidCoolers.unit.cc
    FluidProperties.unit.cc
    FuelCellElectricGenerator.unit.cc
    Furnaces.unit.cc
    General.unit.cc
    GeneralRoutines.unit.cc
    GroundHeatExchangers/Base.unit.cc
    GroundHeatExchangers/BoreholeArray.unit.cc
    GroundHeatExchangers/BoreholeSingle.unit.cc
    GroundHeatExchangers/Properties.unit.cc
    GroundHeatExchangers/ResponseFactors.unit.cc
    GroundHeatExchangers/Slinky.unit.cc
    GroundHeatExchangers/Vertical.unit.cc
    HVACControllers.unit.cc
    HVACCooledBeam.unit.cc
    HVACDXSystem.unit.cc
    HVACDXHeatPumpSystem.unit.cc
    HVACFan.unit.cc
    HVACFourPipeBeam.unit.cc
    HVACHXAssistedCoolingCoil.unit.cc
    HVACInterfaceManager.unit.cc
    HVACManager.unit.cc
    HVACMultiSpeedHeatPump.unit.cc
    HVACSizingSimulationManager.unit.cc
    HVACStandaloneERV.unit.cc
    HVACUnitaryBypassVAV.unit.cc
    HVACVariableRefrigerantFlow.unit.cc
    HWBaseboardRadiator.unit.cc
    HeatBalFiniteDiffManager.unit.cc
    HeatBalanceAirManager.unit.cc
    HeatBalanceIntRadExchange.unit.cc
    HeatBalanceKivaManager.unit.cc
    HeatBalanceManager.unit.cc
    HeatBalanceMovableInsulation.unit.cc
    HeatBalanceSurfaceManager.unit.cc
    HeatPumpWaterToWaterSimple.unit.cc
    HeatRecovery.unit.cc
    HeatingCoils.unit.cc
    HighTempRadiantSystem.unit.cc
    Humidifiers.unit.cc
    HybridModel.unit.cc
    ICEngineElectricGenerator.unit.cc
    ICSCollector.unit.cc
    IceThermalStorage.unit.cc
    IdfParser.unit.cc
    IndoorGreen.unit.cc
    InputProcessor.unit.cc
    IntegratedHeatPump.unit.cc
    InternalHeatGains.unit.cc
    KusudaAchenbachGroundTemperatureModel.unit.cc
    LowTempRadiantSystem.unit.cc
    Material.unit.cc
    MicroCHPElectricGenerator.unit.cc
    MicroturbineElectricGenerator.unit.cc
    MixedAir.unit.cc
    MixerComponent.unit.cc
    MoistureBalanceEMPD.unit.cc
    NodeInputManager.unit.cc
    OASystemHWPreheatCoil.unit.cc
    OccupantDiversity.unit.cc
    OutAirNodeManager.unit.cc
    OutdoorAirUnit.unit.cc
    OutputFiles.unit.cc
    OutputProcessor.unit.cc
    OutputReportData.unit.cc
    OutputReportTabular.unit.cc
    OutputReportTabularAnnual.unit.cc
    OutputReports.unit.cc
    OutsideEnergySources.unit.cc
    PVWatts.unit.cc
    PackagedTerminalHeatPump.unit.cc
    PCMThermalTank.unit.cc
    Photovoltaics.unit.cc
    PhotovoltaicThermalCollectors.unit.cc
    PierceSurface.unit.cc
    Pipes.unit.cc
    Plant/Branch.unit.cc
    Plant/Subcomponent.unit.cc
    PlantCentralGSHP.unit.cc
    PlantChillers.unit.cc
    PlantComponentTemperatureSources.unit.cc
    PlantCondLoopOperation.unit.cc
    PlantHeatExchangerFluidToFluid.unit.cc
    PlantLoadProfile.unit.cc
    PlantLoopHeatPumpEIR.unit.cc
    PlantManager.unit.cc
    PlantPipingSystemsManager.unit.cc
    PlantUtilities.unit.cc
    PollutionModule.unit.cc
    PoweredInductionUnits.unit.cc
    Psychrometrics.unit.cc
    Pumps.unit.cc
    PurchasedAirManager.unit.cc
    RefrigeratedCase.unit.cc
    ReportCoilSelection.unit.cc
    ResultsFramework.unit.cc
    RoomAirModelUserTempPattern.unit.cc
    RoomAirflowNetwork.unit.cc
    RootFinder.unit.cc
    RunPeriod.unit.cc
    RuntimeLanguageProcessor.unit.cc
    SQLite.unit.cc
    SZVAVModel.unit.cc
    ScheduleManager.unit.cc
    SecondaryDXCoils.unit.cc
    SetPointManager.unit.cc
    SimAirServingZones.unit.cc
    SimulationManager.unit.cc
    SingleDuct.unit.cc
    SiteBuildingSurfaceGroundTemperatures.unit.cc
    SiteDeepGroundTemperatures.unit.cc
    SiteFCFactorMethodGroundTemperatures.unit.cc
    SiteGroundDomain.unit.cc
    SiteShallowGroundTemperatures.unit.cc
    SizeWaterHeatingCoil.unit.cc
    SizingAnalysisObjects.unit.cc
    SizingManager.unit.cc
    SolarCollectors.unit.cc
    SolarShading.unit.cc
    Standard621SimplifiedProcedure.unit.cc
    StandardRatings.unit.cc
    StringUtilities.unit.cc
    SurfaceGeometry.unit.cc
    SurfaceOctree.unit.cc
    SurfaceGroundHeatExchanger.unit.cc
    SwimmingPool.unit.cc
    SystemAvailabilityManager.unit.cc
    SystemReports.unit.cc
    Timer.unit.cc
    ThermalChimney.unit.cc
    ThermalComfort.unit.cc
    TranspiredCollector.unit.cc
    UnitHeater.unit.cc
    UnitVentilator.unit.cc
    UFADManager.unit.cc
    UnitaryHybridAirConditioner.unit.cc
    UnitarySystem.unit.cc
    UtilityRoutines.unit.cc
    VAVDefMinMaxFlow.unit.cc
    VariableSpeedCoils.unit.cc
    Vector.unit.cc
    Vectors.unit.cc
    VentilatedSlab.unit.cc
    WaterCoils.unit.cc
    WaterManager.unit.cc
    WaterThermalTanks.unit.cc
    WaterToAirHeatPump.unit.cc
    WaterToAirHeatPumpSimple.unit.cc
    WaterUse.unit.cc
    WeatherManager.unit.cc
    WinCalcEngine.unit.cc
    WindowAC.unit.cc
    WindTurbine.unit.cc
    WindowEquivalentLayer.unit.cc
    WindowLayerEffectiveMultipliers.unit.cc
    WindowManagerExteriorThermal.unit.cc
    WindowManager.unit.cc
    XingGroundTemperatureModel.unit.cc
    ZoneContaminantPredictorCorrector.unit.cc
    ZoneEquipmentManager.unit.cc
    ZoneHVACEvaporativeCooler.unit.cc
    ZonePlenum.unit.cc
    ZoneTempPredictorCorrector.unit.cc
    CommandLineInterface.unit.cc
    main.cc)

set(test_dependencies energypluslib energyplusapi)

if(LINK_WITH_PYTHON)
  add_compile_definitions(LINK_WITH_PYTHON)
  include_directories(${Python_INCLUDE_DIRS})
  if(CMAKE_HOST_UNIX)
    #list(APPEND test_src api/datatransfer.unit.cc) # Requires API; will be moved
    list(APPEND test_src PluginManager.unit.cc)
    list(APPEND test_dependencies ${Python_LIBRARIES})
  endif()
endif()

if(CMAKE_HOST_UNIX AND NOT APPLE)
  list(APPEND test_dependencies dl)
endif()

# Executable name will be EnergyPlus_tests
# Execute energyplus_tests --help for options using gtest runner
# Execute energyplus_tests with no arguments to run all tests
create_test_targets(energyplus "${test_src}" "${test_dependencies}" True)

# For CommandLineInterface.unit.cc, make an in.idf / in.epw in the test directory so we can test the legacy CLI (applies to CTest which sets the current directory to this one)
configure_file("${PROJECT_SOURCE_DIR}/weather/USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw" "${CMAKE_CURRENT_BINARY_DIR}/in.epw" COPYONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/Resources/UnitaryHybridUnitTest_DOSA.idf" "${CMAKE_CURRENT_BINARY_DIR}/in.idf" COPYONLY)
